package com.ruoyi.project.system.collaboration_intents.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.collaboration_intents.domain.CollaborationIntents;
import com.ruoyi.project.system.collaboration_intents.service.ICollaborationIntentsService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * collaboration_intentsController
 * 
 * @author admin
 * @date 2025-04-24
 */
@Controller
@RequestMapping("/cross/collaboration_intents")
public class CollaborationIntentsController extends BaseController
{
    private String prefix = "cross/collaboration_intents";

    @Autowired
    private ICollaborationIntentsService collaborationIntentsService;

    @RequiresPermissions("cross:collaboration_intents:view")
    @GetMapping()
    public String collaboration_intents()
    {
        return prefix + "/collaboration_intents";
    }

    /**
     * 查询collaboration_intents列表
     */
    @RequiresPermissions("cross:collaboration_intents:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CollaborationIntents collaborationIntents)
    {
        startPage();
        List<CollaborationIntents> list = collaborationIntentsService.selectCollaborationIntentsList(collaborationIntents);
        return getDataTable(list);
    }

    /**
     * 导出collaboration_intents列表
     */
    @RequiresPermissions("cross:collaboration_intents:export")
    @Log(title = "collaboration_intents", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CollaborationIntents collaborationIntents)
    {
        List<CollaborationIntents> list = collaborationIntentsService.selectCollaborationIntentsList(collaborationIntents);
        ExcelUtil<CollaborationIntents> util = new ExcelUtil<CollaborationIntents>(CollaborationIntents.class);
        return util.exportExcel(list, "collaboration_intents数据");
    }

    /**
     * 新增collaboration_intents
     */
    @RequiresPermissions("cross:collaboration_intents:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存collaboration_intents
     */
    @RequiresPermissions("cross:collaboration_intents:add")
    @Log(title = "collaboration_intents", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CollaborationIntents collaborationIntents)
    {
        return toAjax(collaborationIntentsService.insertCollaborationIntents(collaborationIntents));
    }

    /**
     * 修改collaboration_intents
     */
    @RequiresPermissions("cross:collaboration_intents:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        CollaborationIntents collaborationIntents = collaborationIntentsService.selectCollaborationIntentsById(id);
        mmap.put("collaborationIntents", collaborationIntents);
        return prefix + "/edit";
    }

    /**
     * 修改保存collaboration_intents
     */
    @RequiresPermissions("cross:collaboration_intents:edit")
    @Log(title = "collaboration_intents", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CollaborationIntents collaborationIntents)
    {
        return toAjax(collaborationIntentsService.updateCollaborationIntents(collaborationIntents));
    }

    /**
     * 删除collaboration_intents
     */
    @RequiresPermissions("cross:collaboration_intents:remove")
    @Log(title = "collaboration_intents", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(collaborationIntentsService.deleteCollaborationIntentsByIds(ids));
    }
}
